﻿using System.Text;

namespace System
{
    public static class StringExtension
    {
        public static string CnPadLeft(this string s, int count)
        {
            int pad = count - Encoding.GetEncoding("gb2312").GetBytes(s).Length;

            return pad > 0 ? new string(' ', pad) + s : s;
        }

        public static string CnPadRight(this string s, int count)
        {
            int pad = count - Encoding.GetEncoding("gb2312").GetBytes(s).Length;

            return pad > 0 ? s + new string(' ', pad) : s;
        }
    }
}